package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.RemoteMasterService;
import com.ruoyi.system.api.domain.WxText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteMasterFallbackFactory implements FallbackFactory<RemoteMasterService> {
    private static final Logger log = (Logger) LoggerFactory.getLogger(RemoteMasterFallbackFactory.class);

    @Override
    public RemoteMasterService create(Throwable throwable) {
        log.error("微信任务处理调用失败:{}", throwable.getMessage());
        return new RemoteMasterService() {
            @Override
            public AjaxResult weixinTask(WxText wxText, String source) {
                return AjaxResult.error("微信任务处理失败:" + throwable.getMessage());
            }

        };
    }
}
